home *** CD-ROM | disk | FTP | other *** search
- ;==========================================================================;
- ; 8250 Timer service ;
- ; This code also used by the QUADRAM QUADPORT board and 4 async port card;
- ; ;
- ; Copyright 1986, 1987, 1988 by H. Roy Engehausen. All rights reserved. ;
- ; This software may be freely distributed and used, but it may not ;
- ; under any circumstances be sold by anyone other than the author. ;
- ; It may be distributed by a commercial company as long as it is ;
- ; for no cost. ;
- ; ;
- ; Permission is explicity granted to use this code as a model for ;
- ; other programs requiring interupt driven serial I/O as long as they ;
- ; carry this copyright notice. ;
- ;==========================================================================;
-
- ;--------------------------------------------------------------------------;
- ; If not time then don't do it. ;
- ;--------------------------------------------------------------------------;
-
- CMP timer_counter,0 ; Timer wrapped?
- JNZ tmr_8250_done ; No... We are done
-
- ;--------------------------------------------------------------------------;
- ; Transmit buffering? If not, nothing to do ;
- ;--------------------------------------------------------------------------;
-
- TEST options[SI],opt_trbuf ; Transmit buffering turned on?
- JZ tmr_8250_done ; No... We are done
-
- ;--------------------------------------------------------------------------;
- ; Transmitter on? If so just turn the flag off ;
- ;--------------------------------------------------------------------------;
-
- TEST flags[SI],flags_xmt_on ; Transmitter on in the last slice?
- JNZ tmr_8250_tx_on ; Yes... Just turn off flag
-
- ;--------------------------------------------------------------------------;
- ; Anything in transmit buffer? If not, we are done ;
- ;--------------------------------------------------------------------------;
-
- MOV AX,buffer_t_in[SI] ; Get buffer input pointer
- CMP AX,buffer_t_out[SI] ; See where the out pointer is
- JE tmr_8250_done ; If they are equal then we have no
-
- ;--------------------------------------------------------------------------;
- ; Oh Oh... The thing might be stuck... Unstuck it.... ;
- ;--------------------------------------------------------------------------;
-
- CLI ; In case someone tries to multiprocess
-
- ; MOV DL,hiv[SI] ; Get the hardware interrupt vector address
- ; MOV tmr_8250_int,DL ; Put it where we need it
- ;
- ; JMP $+2 ; Clean out the prefetch stack
- ; INT 00H ; Interrupt!
- ; ORG $-1
- ;mr_8250_int DB ? ; Place to put interrupt number
- ;
-
- ;--------------------------------------------------------------------------;
- ; Cause an interrupt by setting the IIR to zero and then back to what it ;
- ; was. This will cause an THR empty interrupt. ;
- ;--------------------------------------------------------------------------;
-
- MOV DX,baseaddr[SI] ; Get base address for chip
- ADD DX,ier_8250 ; Address IER
- IN AL,DX ; Get it
- MOV AH,AL ; Save it
- SUB AL,AL ; Now send zero
- OUT DX,AL ; to IER
- MOV AL,AH ; Now restore IER
- JMP $+2 ; Delay
- OUT DX,AL ;
-
- STI ;
-
- JMP SHORT tmr_8250_done
-
- ;--------------------------------------------------------------------------;
- ; Clear transmit flag ;
- ;--------------------------------------------------------------------------;
-
- tmr_8250_tx_on:
-
- AND flags[SI],0FFH-flags_xmt_on ; Turn off transmitter flag
-
- ;--------------------------------------------------------------------------;
- ; All timer functions for 8250 are done ;
- ;--------------------------------------------------------------------------;
-
- tmr_8250_done: